SDF Classes
-
DictIterator is used to traverse key/value pairs in a dictionary. For example a DictIterator can be used to print out all the entries in a given Obj dictionary as follows:
See moreDictIterator itr = dict.GetDictIterator(); while (itr.HasNext()) { Obj key = itr.Key(); cout << key.GetName() << endl; Obj value = itr.Value(); // ... itr.Next() }
Declaration
Objective-C
@interface PTDictIterator : NSObject
Swift
class PTDictIterator : NSObject
-
A NameTree is a common data structure in PDF. See section 3.8.5 ‘Name Trees’ in PDF Reference Manual for more details.
A name tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NameTrees allow efficient storage of very large association collections (string/Obj* maps). A NameTree can have many more entries than a SDF/Cos dictionary can.
NameTree-s use SDF/Cos-style strings (not null-terminated C strings), which may use Unicode encoding etc.
See morePDFDoc doc("../Data/PDFReference.pdf"); NameTree dests = NameTree::Find(*doc.GetSDFDoc(), "Dests"); if (dests.IsValid()) { // Traversing the NameTree UString key; for (DictIterator i = dests.GetIterator(); i.HasNext(); i.Next()) i.Key().GetAsPDFText(key); // ... }
Declaration
Objective-C
@interface PTNameTree : NSObject
Swift
class PTNameTree : NSObject
-
A NumberTree is a common data structure in PDF. See section 3.8.6 ‘Number Trees’ in PDF Reference Manual for more details.
A number tree serves a similar purpose to a dictionary - associating keys and values - but by different means. NumberTrees allow efficient storage of very large association collections (number/Obj* maps). A NumberTree can have many more entries than a SDF/Cos dictionary can.
Sample code:
See morePDFDoc doc("../Data/test.pdf"); NumberTree labels(doc.GetRoot().Get("PageLabels").Value()); if (labels.IsValid()) { // Traversing the NumberTree for (NumberTreeIterator i = labels.GetIterator(); i.HasNext(); i.Next()) cout << "Key: " << i.Key().GetNumber() << endl; }
Declaration
Objective-C
@interface PTNumberTree : NSObject
Swift
class PTNumberTree : NSObject
-
Obj is a concrete class for all SDF/Cos objects. Obj hierarchy implements the composite design pattern. As a result, you can invoke a member function of any ‘derived’ object through Obj interface. If the member function is not supported (e.g. if you invoke Obj::GetNumber() on a boolean object) an Exception will be thrown.
You can use GetType() or obl.Is???() member functions to find out type-information at run time, however most of the time the type can be inferred from the PDF specification. Therefore when you call Doc::GetTrailer() you can assume that returned object is a dictionary. If there is any ambiguity use Is???() methods.
Objects can’t be shared across documents, however you can use Doc::ImportObj() to copy objects from one document to another.
Objects can be shared within a document provided that they are created as indirect. Indirect objects are the ones that are referenced in cross-reference table. To create an object as indirect use doc.CreateIndirect???() (where ? is the Object type).
See moreDeclaration
Objective-C
@interface PTObj : NSObject
Swift
class PTObj : NSObject
-
ObjSet is a lightweight container that can hold a collection of SDF objects.
See moreDeclaration
Objective-C
@interface PTObjSet : NSObject
Swift
class PTObjSet : NSObject
-
SDFDoc is a low-level document representing a graph of SDF::Obj nodes that can be used to build higher-level document models such as PDF (Portable Document Format) or FDF (Forms Document Format).
SDFDoc brings together document security, document utility methods, and all SDF objects.
A SDF document can be created from scratch using a default constructor:
SDFDoc mydoc; Obj trailer = mydoc.GetTrailer();
SDF document can be also created from an existing file (e.g. an external PDF document):
SDFDoc mydoc("in.pdf"); Obj trailer = mydoc.GetTrailer();
or from a memory buffer or some other Filter/Stream such as a HTTP Filter connection:
MemoryFilter memory = .... SDFDoc mydoc(memory); Obj trailer = mydoc.GetTrailer();
Finally SDF document can be accessed from a high-level PDF document as follows:
PDFDoc doc("in.pdf"); SDFDoc& mydoc = doc.GetSDFDoc(); Obj trailer = mydoc.GetTrailer();
Note that the examples above used doc.GetTrailer() in order to access document trailer, the starting SDF object (root node) in every document. Following the trailer links, it is possible to visit all low-level objects in a document (e.g. all pages, outlines, fonts, etc).
SDFDoc also provides utility methods used to import objects and object collections from one document to another. These methods can be useful for copy operations between documents such as a high-level page merge and document assembly.
See moreDeclaration
Objective-C
@interface PTSDFDoc : NSObject
Swift
class PTSDFDoc : NSObject
-
Standard Security Handler is a standard password-based security handler.
See moreDeclaration
Objective-C
@interface PTSecurityHandler : NSObject
Swift
class PTSecurityHandler : NSObject
-
A base class for SignatureHandler. SignatureHandler instances are responsible for defining the digest and cipher algorithms to create and/or validate a signed PDF document. SignatureHandlers are added to PDFDoc instances by calling the PDFDoc::AddSignatureHandler method.
See moreDeclaration
Objective-C
@interface PTSignatureHandler : NSObject { void *m_cPtr; }
Swift
class PTSignatureHandler : NSObject